package com.all.knife4j.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author LY
 * @create 2024/2/28 17:56
 * @Description knife4j
 */
@RestController
@RequestMapping("/api/demo1")
@Tag(name = "测试一：接口文档示例")
@Slf4j
public class Knife4jController1 {

    @Operation(summary = "普通body请求")
    @PostMapping("/body")
    public ResponseEntity<Object> body(String name){
        return ResponseEntity.ok(name);
    }

    @Operation(summary = "普通body请求+Param+Header+Path")
    @Parameters({
            @Parameter(name = "id",description = "文件id",in = ParameterIn.PATH),
            @Parameter(name = "token",description = "请求token",required = true,in = ParameterIn.HEADER),
            @Parameter(name = "name",description = "文件名称",required = true,in=ParameterIn.QUERY)
    })
    @PostMapping("/bodyPath/{id}")
    public ResponseEntity<Object> bodyPath(@PathVariable("id") String id,
                                                        @RequestParam("token") String token,
                                                        @RequestParam("name") String name){
        String param = "name:"+name+",token:"+token+",pathID:"+id;
        return ResponseEntity.ok(param);
    }
}
